/*
 * 作者: 黄伟
 * 时间: 2017-03-01 
 * 说明：
 * Copyright (c) 2016-2017 中研沃兮
 */
define(function(require){
	require("jquery");
	
//	630 * 200
	var appInfo = require("app/AppInfo");
	var action = require("./action/IndexHomePageFrmAction");
	var c = require('app/utils/CommonUtils');
	var APIUtils = require('app/utils/APIUtils');

	var RoomInfoUtils = require('app/utils/RoomInfoUtils');
	
	var scroll_w = APIUtils.winW();
	var scroll_h = parseInt(scroll_w * 20 / 63);
	$("#scroll_pic").height(scroll_h);
	
	var win = window;
	win.header_h = c.remToPx(2.25);
	win.footer_h = 50;
	
//	var room_cover_w = (APIUtils.winW() - c.remToPx(0.125*2 + 1.5))/2;
//	var room_cover_h = parseInt(room_cover_w * 9 / 16);
//	
//	$(".cover-image").height(room_cover_h);
//	$(".cover-image").width(room_cover_w);
	
	action.showScrollPicture();
	
	var hot_catalog = RoomInfoUtils.getRoomCatalogByText("热门",true);
	var new_catalog = RoomInfoUtils.getRoomCatalogByText("全部",true);
	
	$("#hot_catalog").click(function(){
		var uuid = hot_catalog.val;
		
		api.openWin({
	        name: 'IndexCatalogWin',
	        url: './IndexCatalogWin.html',
	        rect: {
	        	x: 0,
	        	y: 0,
	        	w: APIUtils.winW(),
	        	h: APIUtils.winH()
	        },
	        pageParam:{
	        	cataloguuid: uuid,
	        	showBanner: false
	        }
        });
		
	});
	
	
	$("#new_catalog").click(function(){
		var uuid = new_catalog.val;
		
		api.openWin({
	        name: 'IndexCatalogWin',
	        url: './IndexCatalogWin.html',
	        rect: {
	        	x: 0,
	        	y: 0,
	        	w: APIUtils.winW(),
	        	h: APIUtils.winH()
	        },
	        pageParam:{
	        	cataloguuid: uuid,
	        	showBanner: false
	        }
        });
	});
	
	//初始化头部刷新
	api.setRefreshHeaderInfo({
		visible: true,
		loadingImg: 'widget://res/pullrefresh/pullpoint.png',
		bgColor: '#ccc',
		textColor: '#fff',
		textDown: '下拉刷新...',
		textUp: '松开刷新...',
		showTime: true
	}, function(ret, err) {
		action.fetchInHeaderMode();
	});

	action.fetchInHeaderMode();
		
	return;
});